<?php
session_start();
include "../includes/comunes.php";
//obtengo el plan vigente

$tabla="plansemanal";
$condicion="PlanId=".$_GET['PlanId'];
$orden=" order by PlanId ";
$result=  cons_sql($tabla, $condicion, $orden);


//echo $_SESSION['PlanId'];

//
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sistema de Registro de Atencion</title>
<!--libreria jquery central-->
<script src="../jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->
<!--librerias ui-->
<link href="../jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="../jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--librerias fullcalendar-->
<script src="../jquery-ui/js/fullcalendar.min.js"></script>
<link href="../jquery-ui/css/fullcalendar/fullcalendar.css" rel="stylesheet"/>
<link href="../jquery-ui/css/fullcalendar/fullcalendar.print.css" rel="stylesheet"/>
<!--fin libreria-->




<script>

	$(document).ready(function() {
	   
		$('#calendar').fullCalendar({
		    header: {
				left: 'prev,next today,',
				center: 'title',
				right: 'month,basicWeek,basicDay'
			},
			editable: false,
			firstday: 2,
			hiddenDays:[ 0 ],
			week: 'ddd d/M', // Mon 9/7
			visStart: 'basicWeek ',
			
			
			events: [
				<?php 
				while ($regPlan=mysql_fetch_array($result)){
				$tabla1="planoperaciones";
				$condicion1=" Plan=".$regPlan['PlanId'];
				$orden1=" order by Carga asc";
				$resultDetalle=  cons_sql($tabla1, $condicion1, $orden1);
				while($reg=mysql_fetch_array($resultDetalle)){
				if ($reg['MostrarObservacion']==1)
						$obs='OBS.:'.$reg['Observacion'];
						else
						$obs="";
						
						//veo si esta suspendido o no
				
                if($reg['Estado']<>3){
					$start = $reg['Carga'];
					$end = $reg['Carga'];
					$title = strtoupper(obtener_sucursal_codigo($reg['Destino']));
			        $descripcion= 'Origen: '.obtener_origen($reg['Origen'],"/").'   PED.:'.format_fec_corta($reg['Pedido'],"/").'  CAR.:'.format_fec_corta($reg['Carga'],"/").' DES.:'.format_fec_corta($reg['Descarga'],"/").' RET.:'.format_fec_corta($reg['Retorno'],"/").' Vehiculo: '.obtener_nombre_vehiculo($reg['Vehiculo']).' Chofer: '.obtener_nombre_chofer($reg['Chofer']). ' '.obtener_pedidos($reg['Id']).' '.$obs;
				
				
				?>
				{
					title: '<?php echo utf8_encode($title) ?>',
					start: '<?php echo $start ?>',
					color: '<?php echo obtener_color_sucursal($reg['Destino']) ?>',
					className : 'custom<?php echo $reg['Destino'] ?>',
					description:'<?php echo utf8_encode($descripcion) ?>',
					url: '<?php echo "des_ModDetalle.php?id=".$reg['Id'] ?>',
					
					
					
				},
			 <?php 
			 }else
			 {
			 $start = $reg['Carga'];
					$end = $reg['Carga'];
					$title = strtoupper(obtener_sucursal_codigo($reg['Destino']));
					$descripcion= ' Motivo: '.obtener_des_motivo_demora($reg['MotivoEstado']).'. ';
			        $descripcion.= 'Envio SUSPENDIDO   Se reprogramara el mismo y se comunicara la reprogramacion';
				
			 ?>
			 {
					title: '<?php echo utf8_encode($title) ?>',
					start: '<?php echo $start ?>',
					color: '<?php echo obtener_color_sucursal($reg['Destino']) ?>',
					className : 'suspendido',
					description:'<?php echo $descripcion ?>',
					<?php if(es_centro($_SESSION['usuSucursal'])==1):?>
					url: '<?php echo "des_ModDetalle.php?id=".$reg['Id'] ?>',
					<?php else:?>
					url:'<?php echo "des_detalle.php?id=".$reg['Id'] ?>'
					<?php endif?>
					
					
				},
			 <?php
			 }
			 }
			 }
			 ?>
			] ,
			
			
			defaultView: 'basicWeek',
			eventClick: function(event) {
				// opens events in a popup window
				window.open(event.url, 'gcalevent', 'width=700,height=700');
				return false;
			},
			loading: function(bool) {
				if (bool) $('#loading').show();
				else $('#loading').hide();
			},
			eventRender: function(event, element)
			{ 
				element.find('.fc-event-title').append("<br/><div id='des'>" + event.description+"</div>"); 
			}
	
		});
		
		$(function() {
             $( "#Origen1" ).tabs(
			 {
			  beforeLoad: function( event, ui ) {
				ui.jqXHR.error(function() {
				  ui.panel.html(
					"Couldn't load this tab. We'll try to fix this as soon as possible. " +
					"If this wouldn't be a demo." );
				});
			  }
					 
			 });
        });
		
		$( "#menu" ).menu({position: {at: "left bottom"}});
		
	});

</script>
<style>

	
		
	#loading {
		position: absolute;
		top: 5px;
		right: 5px;
		}

	#calendar {
		width: 900px;
		margin-left:-50px;
		}
		

<?php 
$resSuc=obtener_sucursales();
while($regSuc=mysql_fetch_array($resSuc)):
?>		
.custom<?php echo $regSuc['sucursalId'] ?>,
.custom<?php echo $regSuc['sucursalId'] ?> div,
.custom<?php echo $regSuc['sucursalId'] ?> span {
    background-color: <?php echo $regSuc['sucursalColor'] ?>; /* background color */
    border-color: <?php echo $regSuc['sucursalColor'] ?>;     /* border color */
    color: white;           /* text color */
}	
<?php endwhile ?>
.suspendido,
.suspendido div,
.suspendido span {
    background-color: #FA5882; /* background color */
    border-color: red;     /* border color */
    color: white;           /* text color */
}	


#des{
font-weight:normal;
opacity: .90;
   -moz-opacity: .90;
   filter:alpha(opacity=90);}
</style>
  
<link href="../estilos.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="container"  style="width: 1000px;">
 <div class="header"><img src="../img/TopCHAMACO.jpg" width="1000" height="100" />
     
  </div>
   <div class="content">
       <div class="tituloprincipal" style="position:relative ;z-index: 100;">Plan de Despachos desde Deposito el Campito
         
           
           </div>
       <div class="contenedor" style="position:relative ;z-index: 1;">
     
	 <div id='loading' style='display:none'>loading...</div>
	 <div style="border:2px solid red; margin-left:-50px;margin-right:50px;margin-bottom:15px;text-align:center;padding:10px;"><b>Fecha ultima actualizacion: <?php echo ultima_actualizacion()?></b></div>
     <div id="Origen1" style="margin-left:-60px;">
	 <ul>
	            <li><a href="#tabs-1">Todos</a></li>
				<li><a href="des_index1.php?PlanId=<?php echo $_GET['PlanId']?>">Origen Campito Terminaciones</a></li>
				<li><a href="des_index2.php?PlanId=<?php echo $_GET['PlanId']?>">Origen Campito Metalurgico</a></li>
				
     </ul>
			   <div id="tabs-1">
					<div id='calendar' style="margin-left:0px;"></div>
			  </div>	
				<div id="tabs-2">
					<div id='calendar1' style="margin-left:0px;"></div>
			  </div>		
			<div id="tabs-3">
					<div id='calendar2' style="margin-left:0px;"></div>
			  </div>
					  
	 </div>
     <span class="fc-button fc-button-today fc-state-default fc-corner-left fc-corner-right" style="margin-left:-50px;" unselectable="on" onclick="window.print()">Imprimir</span>
       </div>
       <div class="clear"></div>
   <br>
   </div>
  <?php include "../includes/pieMedio.php"?>
  
</div>
</body>
</html>
